package com.ruoyi.scale.utils;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.springframework.boot.jackson.JsonComponent;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat;

@JsonComponent
public class CustomerJsonComponent {

    public static class Serializer extends JsonSerializer<Double> {
        DecimalFormat format = new DecimalFormat("0.#");
        @Override
        public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
            if (value != null) {
                gen.writeString(format.format(value));
            }
        }


    }

//       public static class Deserializer extends JsonDeserializer<Customer> {
//
//           // ...
//
//       }

}